abstract class Package {
  // 构造函数
  constructor(public weight: number) {}
  // 抽象函数
  abstract calculate(): number;
  // 具体函数
  printPackage() {
    console.log(`包裹${this.calculate()}`);
  }
}

class StandardPackage extends Package {
  constructor(weight: number, public price: number) {
    super(weight);
  }
  // 重写抽象函数
  calculate(): number {
    return this.weight * this.price;
  }
}

// 获取实例
const s1 = new StandardPackage(10, 2);
s1.printPackage();
